#include <bits/stdc++.h>
using namespace std;
//Update Executable File
int main(int argc,char *argv[]) {
	system("pip -q install bs4");//https://raw.gitcode.com/Qihonghao_/Verson/raw/main/ver
	system("cls"); 
	cout<<"准备中 20%";
	system("pip -q install requests");
	system("cls"); 
	cout<<"准备中 40%";
	ofstream fout("verchecker.py");
	fout<<"from requests import get\n\
from bs4 import BeautifulSoup\n\
import os\n\
\n\
url = \"https://raw.gitcode.com/Qihonghao_/Verson/raw/main/ver\"\n\
\n\
try:\n\
    response = get(url, timeout=10)\n\
    #response.raise_for_status()\n\
\n\
    soup = BeautifulSoup(response.text, 'html.parser')\n\
\n\
    text = soup.get_text()\n\
\n\
    with open(f\"./vernew.ver\", 'w', encoding='utf-8') as f:\n\
        f.write(text)\n\
except Exception as e:\n\
    with open(f\"./vernew.ver\", 'w', encoding='utf-8') as f:\n\
        f.write(f\"Net Error\")\n";
    fout.close();
    fout.open("juqingdowner.py");
	fout<<"from requests import get\n\
from bs4 import BeautifulSoup\n\
import os\n\
\n\
url = \"https://raw.gitcode.com/Qihonghao_/Verson/raw/main/latest.juq\"\n\
\n\
try:\n\
    response = get(url, timeout=10)\n\
    #response.raise_for_status()\n\
\n\
    soup = BeautifulSoup(response.text, 'html.parser')\n\
\n\
    text = soup.get_text()\n\
\n\
    with open(f\"./juq.juq\", 'w', encoding='utf-8') as f:\n\
        f.write(text)\n\
except Exception as e:\n\
    with open(f\"./juq.juq\", 'w', encoding='utf-8') as f:\n\
        f.write(f\"Net Error\")\n";
    fout.close();
    fout.open("verson.ver");
    fout<<"1.0.0";
    fout.close();
	fout.open("gamedown.py");
	fout<<"import requests\n\
import os\n\
try:\n\
    url = \"https://gitee.com/qihonghao/game-update/raw/master/Game.exe\"\n\
    save_path = \"game.exe\"\n\
    response = requests.get(url, stream=True)\n\
    response.raise_for_status()\n\
    \n\
    with open(save_path, \"wb\") as f:\n\
        for chunk in response.iter_content(chunk_size=8192):\n\
            f.write(chunk)\n\
            \n\
except Exception as e:\n\
    print(f\"Error: {e}\")";
	fout.close();
	string path1 = argv[0];
	for(int i=path1.length()-1,j=0;j<=7;i--,j++) path1.erase(i,1);
	string path = "python.exe " + path1 + "verchecker.py";
	system(path.c_str());
	path = "python.exe " + path1 + "gamedown.py";
	system(path.c_str());
	return 0;
}